<template>
  <div class="all-job-resume">
    <div class="all-job-resume-head">
      <el-col :span="23">
        <span class="all-job-resume-line"></span>
        执业证书
        <span class="all-job-resume-sub-text">必填</span>
      </el-col>
      <el-col :span="1" v-if="data.length < 3">
        <i class="el-icon-circle-plus plus-add" @click="addContent"></i>
      </el-col>
    </div>

    <!-- 执业证书中的某一条 -->
    <practice-certificate-list
      :practiceType="practiceType"
      :form="form"
      v-for="(item,index) in data"
      :key="index"
      :data="item"
      @on-pitch="cancel"
      :lengths="data.length"
    ></practice-certificate-list>
    <!-- 执业证书中的某一条 -->

    <div class="edit-content" v-if="form.sta == 4 && form.editSta == -1">
      <div class="all-job-resume" style="padding:24px 0 0 0; background:#f7fdff;">
        <el-form label-width="100px" label-position="right">
          <el-row>
            <el-col :span="12">
              <el-form-item label="执业类型">
                <!-- <el-select class="all-input" v-model="params.licenseType">
                  <el-option
                    v-for="(item,index) in practiceType"
                    :key="index"
                    :value="item.id"
                    :label="item.content"
                  ></el-option>
                </el-select>-->
                <el-cascader
                  :options="practiceType||[]"
                  :props="props"
                  v-model="params.licenseType"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="11" :offset="1">
              <el-form-item label="证书编号">
                <el-input class="theme-input all-input" v-model="params.licenseNum"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item class="form-button-right">
            <el-button class="ghost-button" @click="cancel">取消</el-button>
            <el-button class="submit-button" @click="doSubmit">确认</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { constants } from 'crypto'
import practiceCertificateList from './list/practice-certificate-list'
export default {
  props: ['form', 'practiceType', 'data'],
  data() {
    return {
      params: {
        licenseId: '',
        licenseNum: '',
        licenseType: []
      },
      props: {
        value: 'licenseTypeId',
        children: 'licenseSonList',
        label: 'licenseType'
      }
    }
  },
  methods: {
    check() {
      if (this.params.licenseNum == '' || this.params.licenseType == []) {
        _g.message('数据不能为空', 'warning')
        return false
      }
      return true
    },
    addContent() {
      //点击添加按钮
      this.form.sta = 4
      this.form.editSta = -1
    },
    cancel() {
      //点击添加按钮
      this.$emit('on-pitch', true)
      this.form.sta = -1
      this.form.editSta = -1
    },
    doSubmit() {
      //点击确定
      if (!this.check()) return false
      let params = {
        licenseId: this.params.licenseId,
        licenseNum: this.params.licenseNum,
        licenseType: this.params.licenseType[1]
      }
      _g.apiPost('/talent/updateLicense.do', params).then(res => {
        _g.toMessage(res.data)
        this.cancel()
        this.emptyData()
      })
    },
    emptyData() {
      this.params.licenseId = ''
      this.params.licenseNum = ''
      this.params.licenseType = []
    }
  },

  components: {
    practiceCertificateList
  }
}
</script>

<style lang="scss" scoped>
</style>
